package starComponent.parallelcoordinates;

import java.awt.Color;
import java.awt.Point;

import starComponent.E_PossibleBranches;

/**
 * @author Charles Perin
 * 11 avr. 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 */
public class ParallelBranchBiSlider extends A_ParallelBranch{

	private ParallelThumb thumbStart, thumbEnd;

	private Color rangeColor;

	private double minRange=0;

	private int rangeThickness=1;

	/**
	 * Branche "biSlider"
	 * @param star le starComponent associe
	 * @param name le nom de la branche
	 * @param min valeur min
	 * @param max valeur max
	 * @param minValue valeur min par defaut
	 * @param maxValue valeur max par defaut
	 * @param color la couleur de la branche
	 * @param ladder l'echelle de valeurs
	 * @param angle l'angle de la branche : [0;2PI]
	 */
	public ParallelBranchBiSlider(ParallelCoordinatesComponent star, E_PossibleBranches branch, int position, Color color, ParallelLadder ladder){
		super(star, branch, position, color, ladder);
		this.setRangeColor(Color.BLACK);
		if(branch.getType()==E_PossibleBranches.QUANTITATIVE_BISLIDER || branch.getType()==E_PossibleBranches.QUANTITATIVE_BISLIDER){
			this.thumbStart = new ParallelThumb(this);
			this.thumbEnd = new ParallelThumb(this);
			thumbStart.setValue(branch.getStartValueMin());
			thumbEnd.setValue(branch.getStartValueMax());
		}
		else System.err.println("StarBranchBiSlider: erreur a la creation de "+branch.getName());
	}

	@Override
	public String toString(){
		return this.getName();
	}

	public double getMinValue() {
		return thumbStart.getValue();
	}

	public void setMinValue(double minValue) {
		this.getThumbStart().setValue(minValue);
	}

	public double getMaxValue() {
		return thumbEnd.getValue();
	}

	public void setMaxValue(double maxValue) {
		this.getThumbEnd().setValue(maxValue);
	}


	public ParallelThumb getThumbStart() {
		return thumbStart;
	}


	public void setThumbStart(ParallelThumb thumbStart) {
		this.thumbStart = thumbStart;
	}


	public ParallelThumb getThumbEnd() {
		return thumbEnd;
	}


	public void setThumbEnd(ParallelThumb thumbEnd) {
		this.thumbEnd = thumbEnd;
	}


	public void setMinRange(double minRange) {
		this.minRange = minRange;
	}


	public double getMinRange() {
		return minRange;
	}

	public Point getMiddle() {
		return new Point((thumbStart.getxPos()+thumbEnd.getxPos())/2, (thumbStart.getyPos()+thumbEnd.getyPos())/2);
	}


	public void setRangeColor(Color rangeColor) {
		this.rangeColor = rangeColor;
	}


	public Color getRangeColor() {
		return rangeColor;
	}


	public void setRangeThickness(int rangeThickness) {
		this.rangeThickness = rangeThickness;
	}


	public int getRangeThickness() {
		return rangeThickness;
	}
}
